package app;

import model.Response;
import service.AliyunRobotServiceImpl;
import service.QkyRobotServiceImpl;
import service.RobotService;

import java.util.Scanner;

public class Main {

    //定义请求实现类对象
    private static final RobotService robotService = new QkyRobotServiceImpl();


    public static void main(String[] args)throws Exception {
        //1.获取用户输入
        Scanner scanner = new Scanner(System.in);
        System.out.println("老板，麻烦您给我取个响亮的名称，按回车键确定！！！！");
        String name = scanner.nextLine();
        System.out.println("hi,我是您的小助手 "+name +", 直接对我下达指令");
        //2.对不同输入作处理
        while (true){

            String input = scanner.nextLine();
            if("886".equalsIgnoreCase(input)){
                System.out.println("欢迎下次使用，拜拜");
                break;
            }else {
              Response response = robotService.qa(input);//通过对象调用请求服务方法


              if(response != null && response.getCode() == 0){//响应正常
                  System.out.println(name+":"+ new String(response.getContent().getBytes(),"UTF-8"));
              }else {
                  System.out.println(name+": 暂时没明白您的意思，重新告诉我下吧");
              }
            }

        }
        scanner.close();


    }
}
